using System;
using System.Windows.Forms;

namespace GTask
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            if (args != null)
            {
                if (args.Length > 1)
                {
                    Glpt.Common.UrlParams ups = new Glpt.Common.UrlParams();
                    ups.URL = "gjaudit://login/";
                    ups.Add("username", args[0]);
                    ups.Add("password", Glpt.Common.MD5.Encrypt2(args[1]));
                    string keyParams = "://login/?FORWARD_PARAMS=";
                    string loginParams = ups.ToString(DateTime.Now); ;
                    int idx = loginParams.IndexOf(keyParams);
                    if (idx > 0)
                    {
                        GClient.FrmLogin.AutoLoginParams = loginParams.Substring(idx + keyParams.Length);
                        FrmMain.TaskFunctionID = 0;
                    }
                }
                else if (args.Length == 1)
                {
                    int itmp = 0;
                    if (int.TryParse(args[0], out itmp))
                    {
                        if (itmp > 0)
                        {
                            GClient.FrmLogin.AutoLoginNotPassword = true;
                            FrmMain.TaskFunctionID = itmp;
                        }
                    }
                }
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FrmMain());
        }
    }
}
